package logic

import (
	"context"
	"house_srv/models/mysql"

	"house_srv/house"
	"house_srv/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type HouseUpdateLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewHouseUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *HouseUpdateLogic {
	return &HouseUpdateLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *HouseUpdateLogic) HouseUpdate(in *house.HouseUpdateRequest) (*house.HouseUpdateResponse, error) {
	// todo: add your logic here and delete this line

	h := mysql.House{}
	h.ID = uint(in.HouseId)
	h.HouseStatus = in.HouseStatus
	err := h.UpdateGetHouse(in.HouseId, in.HouseStatus)
	if err != nil {
		logx.Error("修改房源审核失败")
		return nil, err
	}
	return &house.HouseUpdateResponse{}, nil
}
